#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void rand_write(FILE* fp,int len,int lower, int upper)
{
    int i;    
    for(i=0;i<len;i++)
    {      
       fputc(rand()%(upper-lower+1)+lower,fp);
    }
    fputc('\n',fp);
}


/* can't finish it*/
void rand_write_noneof(FILE* fp,int len,int lower, int upper)
{
    int i;
    int rd;    
    for(i=0;i<len;i++)
    {      
       rd=rand()%(upper-lower+1)+lower;
       if((rd==152)||(rd==3)||(rd==4))
        {
        //printf("the %d is %d\n",i,rd);
        continue;
        }
       else fputc(rd,fp);
    }
    fputc('\n',fp);
}

void test_1()
{
    FILE *fp;
	int i=0;
	fp=fopen("test1.in","wb+");
	for (i=0;i<1000;i++)
    {
        rand_write(fp,63,32,126);
        rand_write(fp,63,32,126);
        fputc('\0',fp);
        rand_write(fp,63,32,126);
    }
    close(fp);
}
void test_2()
{
    FILE *fp;
	int i=0;
	fp=fopen("test2.in","wb+");
	for (i=0;i<1000;i++)
    {
        rand_write(fp,63,32,126);
        fputc('\n',fp);
        rand_write(fp,63,32,126);
    }
    close(fp);
}

void test_3()
{
    FILE *fp;
	int i=0;
	fp=fopen("test3.in","wb+");
	for (i=0;i<1000;i++)
    {
        rand_write(fp,127,32,126);
        fputc('\0',fp);
        rand_write(fp,63,32,126);
    }
    close(fp);
}

void test_4()
{
    FILE *fp;
	int i=0;
	fp=fopen("test4.in","wb+");
	for (i=0;i<5;i++)
    {
        rand_write(fp,127,0,127);
        fputc(0,fp);
        rand_write(fp,62,0,127);
        fputc('\n',fp);
        rand_write(fp,63,0,127);
    }
    close(fp);
}

void test_5()
{
    FILE *fp;
	int i=0;
	fp=fopen("test5.in","wb+");
	for (i=0;i<5;i++)
    {
        rand_write(fp,127,0,127);
        fputc(EOF,fp);
        rand_write(fp,63,32,128);
    }
    close(fp);
}

void test_6()
{
    FILE *fp;
	int i=0,j=0;
	fp=fopen("test6.in","wb+");
	for (i=0;i<5;i++)
    {
        for(j=0;j<10;j++)
        {
            fputc(rand()%(126-32+1)+32,fp);
        }
        fputc(EOF,fp);
        for(j;j<127;j++)
        {
            fputc(rand()%(126-32+1)+32,fp);
        }
        fputc('\n',fp);
    }
    close(fp);
}

void test_7()
{
    FILE *fp;
	int i=0,j=0;
	fp=fopen("test7.in","wb+");
	for (i=0;i<5;i++)
    {
        for(j=0;j<10;j++)
        {
            fputc(rand()%(126-32+1)+32,fp);
        }
        fputc('\0',fp);
        for(j;j<30;j++)
        {
            fputc(rand()%(126-32+1)+32,fp);
        }
        fputc('\n',fp);
    }
    close(fp);
}

void test_8()
{
    FILE *fp;
	int i=0,j=0;
	fp=fopen("test8.in","wb+");
	for (i=0;i<5;i++)
    {
        rand_write_noneof(fp,30,128,255);
        rand_write_noneof(fp,63,128,255);
        rand_write_noneof(fp,10,32,255);
    }
    close(fp);
}



int main(int argc, char const *argv[])
{
	srand( (unsigned)time(NULL));
	test_1();
	test_2();
	test_3();
	test_4();
	test_5();
	test_6();
	test_7();
	test_8();
	return 0;
}
